from django.contrib import admin
from .models import *

class StoryInline(admin.StackedInline):
    model = Story  # 内嵌模型

@admin.register(StoryType)
class StoryTypeAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "type"]
    # 过滤器
    list_filter = ["is_delete"]
    # 搜索框
    search_fields = ["type"]
    inlines = [StoryInline]


@admin.register(Story)
class StoryAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "type", "title", "short", "title_img", "desc"]
    # 过滤器
    list_filter = ["is_delete","type"]
    # 搜索框
    search_fields = ["title", "short"]




